<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>OpenLayers v8.2.0 API - Module: ol/events/condition</title>
    <script src="scripts/prettify/prettify.js"></script>
    <script src="scripts/prettify/lang-css.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js"
        crossorigin="anonymous"></script>
    <link rel="stylesheet" type="text/css"
        href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css"
        href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.2/css/fontawesome.min.css"
        crossorigin="anonymous">
    <link rel="stylesheet" type="text/css"
        href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.2/css/solid.css" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css"
        href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.1.2/css/brands.css" crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="styles/prettify-tomorrow.css">
    <link rel="stylesheet" type="text/css" href="styles/jaguar.css">
    <link rel="stylesheet" type="text/css" href="styles/carbon.css">
    <link rel="stylesheet" type="text/css" href="/theme/ol.css">
    <link rel="stylesheet" type="text/css" href="/theme/site.css">
</head>

<body>
    <header class="navbar navbar-expand-sm navbar-dark mb-3 px-3 py-0 fixed-top" role="navigation">
        <a class="navbar-brand" href="/"><img src="/theme/img/logo-dark.svg" width="70" height="70"
                alt="">&nbsp;OpenLayers</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#olmenu"
            aria-controls="olmenu" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <!-- menu items that get hidden below 768px width -->
        <nav class="collapse navbar-collapse" id="olmenu">
            <ul class="nav navbar-nav ms-auto">
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="docdropdown" role="button"
                        data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Docs</a>
                    <div class="dropdown-menu dropdown-menu-end mb-3" aria-labelledby="docdropdown">
                        <a class="dropdown-item" href="/doc/">Docs</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="/doc/quickstart.html"><i
                                class="fa fa-check fa-fw me-2 fa-lg"></i>快速入门</a>
                        <a class="dropdown-item" href="/doc/faq.html"><i
                                class="fa fa-question fa-fw me-2 fa-lg"></i>FAQ</a>
                        <a class="dropdown-item" href="/doc/tutorials/"><i
                                class="fa fa-book fa-fw me-2 fa-lg"></i>Tutorials</a>
                        <div class="dropdown-divider"></div>
                        <a class="dropdown-item" href="https://stackoverflow.com/questions/tagged/openlayers"><i
                                class="fab fa-stack-overflow fa-fw me-2"></i>Ask a Question</a>
                    </div>
                </li>
                <li class="nav-item"><a class="nav-link" href="/en/latest/examples/">Examples</a></li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="apidropdown" role="button"
                        data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        <i class="fa fa-sitemap me-1"></i>API
                    </a>
                    <div class="dropdown-menu dropdown-menu-end mb-3" aria-labelledby="apidropdown">
                        <a class="dropdown-item" href="/en/latest/apidoc/"><i
                                class="fa fa-sitemap fa-fw me-2 fa-lg"></i>v8.2.0
                            (latest)</a </div>
                </li>
            </ul>
        </nav>
    </header>

    <div class="container-fluid">
        <div id="wrap" class="row">
            <div class="navigation col-md-4 col-lg-3">
                <div class="search-wrapper">
                    <div class="search">
                        <input id="search" type="text" autocomplete="off" class="form-control input-sm"
                            placeholder="Search Documentation">
                    </div>
                </div>
                <div class="navigation-list-wrapper">
                    <ul class="navigation-list search-empty">
                        <li class="item item-module toggle-manual toggle-manual-show"
                            data-longname="module:ol/events/condition" data-name="ol/events/condition">
                            <span class="title toggle">
                                <span class="fa fa-plus me-2 mt-1"></span>
                                <span><a href="module-ol_events_condition.html">ol​/events​/condition</a></span>
                            </span>
                            <div class="member-list" data-type="members">
                                <span class="subtitle">Members</span>
                                <ul>
                                    <li data-name="altkeyonly"><a
                                            href="module-ol_events_condition.html#.altKeyOnly">altKeyOnly</a>
                                    <li data-name="altshiftkeysonly"><a
                                            href="module-ol_events_condition.html#.altShiftKeysOnly">altShiftKeysOnly</a>
                                    <li data-name="always"><a href="module-ol_events_condition.html#.always">always</a>
                                    <li data-name="click"><a href="module-ol_events_condition.html#.click">click</a>
                                    <li data-name="doubleclick"><a
                                            href="module-ol_events_condition.html#.doubleClick">doubleClick</a>
                                    <li data-name="focus"><a href="module-ol_events_condition.html#.focus">focus</a>
                                    <li data-name="mouseonly"><a
                                            href="module-ol_events_condition.html#.mouseOnly">mouseOnly</a>
                                    <li data-name="never"><a href="module-ol_events_condition.html#.never">never</a>
                                    <li data-name="nomodifierkeys"><a
                                            href="module-ol_events_condition.html#.noModifierKeys">noModifierKeys</a>
                                    <li data-name="penonly"><a
                                            href="module-ol_events_condition.html#.penOnly">penOnly</a>
                                    <li data-name="platformmodifierkey"><a
                                            href="module-ol_events_condition.html#.platformModifierKey">platformModifierKey</a>
                                    <li data-name="platformmodifierkeyonly"><a
                                            href="module-ol_events_condition.html#.platformModifierKeyOnly">platformModifierKeyOnly</a>
                                    <li data-name="pointermove"><a
                                            href="module-ol_events_condition.html#.pointerMove">pointerMove</a>
                                    <li data-name="primaryaction"><a
                                            href="module-ol_events_condition.html#.primaryAction">primaryAction</a>
                                    <li data-name="shiftkeyonly"><a
                                            href="module-ol_events_condition.html#.shiftKeyOnly">shiftKeyOnly</a>
                                    <li data-name="singleclick"><a
                                            href="module-ol_events_condition.html#.singleClick">singleClick</a>
                                    <li data-name="targetnoteditable"><a
                                            href="module-ol_events_condition.html#.targetNotEditable">targetNotEditable</a>
                                    <li data-name="touchonly"><a
                                            href="module-ol_events_condition.html#.touchOnly">touchOnly</a>
                                </ul>
                            </div>
                            <div class="member-list" data-type="typedefs">
                                <span class="subtitle">Typedefs</span>
                                <ul>
                                    <li data-name="condition"><a
                                            href="module-ol_events_condition.html#~Condition">Condition</a>
                                </ul>
                            </div>
                        <li class="loading">Loading …
                    </ul>
                </div>
            </div>

            <div class="main col-md-8 col-lg-9">
                <h1 class="page-title" data-filename="module-ol_events_condition.html">Module: ol/events/condition</h1>
                <div id="latest-check" class="alert alert-warning alert-dismissible" role="alert" style="display:none">
                    <button id="latest-dismiss" type="button" class="btn-close" data-bs-dismiss="alert"
                        aria-label="Close"></button>
                    This documentation is for OpenLayers v<span id="package-version">8.2.0</span>. The <a
                        id="latest-link" href="#" class="alert-link">latest</a> is v<span id="latest-version"></span>.
                </div>




                <section class="content">

                    <header>
                        <h2 class="my-3">ol/events/condition
                        </h2>
                        <br>




                        <div class="row p-3 ">
                            <!-- <div id="ad" class="col-lg-5 order-2 align-self-center border rounded bg-light ">
                                <script async type="text/javascript"
                                    src="https://cdn.carbonads.com/carbon.js?serve=CE7DV53U&placement=openlayersorg"
                                    id="_carbonads_js"></script>
                            </div> -->

                        </div>
                    </header>

                    <article>
                        <div class="container-overview">






                            <dl class="details">





















                            </dl>




                        </div>
















                        <h3 class="subsection-title">Members</h3>

                        <dl>

                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".altKeyOnly">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.altKeyOnly


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果只按下了alt 键，则返回<code>true</code> , 如果还按下了其他键（例如 shift 键），则返回<code>false</code>。
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".altShiftKeysOnly">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.altShiftKeysOnly


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果只按下了alt和shift键，则返回<code>true</code> ,
                                        如果还按下了其他键（例如其他额外修饰键），则返回<code>false</code>。
                                    </p>

                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".always">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.always


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>始终返回true。</p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".click">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.click


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果是<code>click</code>事件返回<code>true</code>，其他事件返回
                                        <code>false</code> 。
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".doubleClick">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.doubleClick


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果是地图的<code>dblclick</code>事件，则返回<code>true</code>，否则返回<code>false</code>。
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".focus">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.focus


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果地图具有焦点，则返回<code>true</code>。此条件需要具有<code>tabindex</code>属性的映射目标元素，例如
                                        <code>&lt;div id=&quot;map&quot; tabindex=&quot;1&quot;&gt;</code>.
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".mouseOnly">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.mouseOnly


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果事件源自鼠标设备，则返回<code>true</code>。</p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".never">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.never


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>始终返回false.</p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".noModifierKeys">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.noModifierKeys


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果未按下修饰键 (alt-, shift- or
                                        platform-modifier-key) ，则返回<code>true</code></p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".penOnly">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.penOnly


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果事件来自数字笔，则返回<code>true</code>。</p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".platformModifierKey">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.platformModifierKey


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果按下修饰键(Mac上的 meta键，其他系统的ctrl 键)被按下，则返回<code>true</code>。</p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".platformModifierKeyOnly">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.platformModifierKeyOnly


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果只按下修饰键(Mac上的 meta键，其他系统的ctrl
                                        键)，则返回<code>true</code>，否则返回<code>false</code>(例如，当另外按下Shift键时)。</p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".pointerMove">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.pointerMove


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果浏览器事件是<code>pointermove</code>事件，则返回<code>true</code>，否则返回
                                        <code>false</code>。
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".primaryAction">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.primaryAction


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果事件来自与表面接触的主指针，或者按下了鼠标左键，则返回 <code>true</code>。
                                        请参见 <a
                                            href="https://www.w3.org/TR/pointerevents/#button-states">https://www.w3.org/TR/pointerevents/#button-states</a>.
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".shiftKeyOnly">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.shiftKeyOnly


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果仅按下了 shift 键，则返回<code>true</code>, 否则返回<code>false</code> (例如，当同时按下 alt 键时)。
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".singleClick">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.singleClick


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果事件是地图的<code>singleclick</code>事件，则返回<code>true</code>，反之返回<code>false</code>。
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".targetNotEditable">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.targetNotEditable


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果目标元素不可编辑，即不是
                                        <code>input</code>,
                                        <code>select</code>, or <code>textarea</code> 元素，并且没有设置或继承
                                        <code>contenteditable</code>属性，则返回<code>true</code>, 否则返回<code>false</code>。
                                    </p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>



                            <dt class="">
                                <div class="nameContainer">
                                    <div class="anchor" id=".touchOnly">
                                    </div>
                                    <h4 class="name">
                                        module:ol/events/condition.touchOnly


                                    </h4>
                                </div>

                            </dt>
                            <dd class="">

                                <div class="description">
                                    <p>如果事件来自可触摸的设备，则返回<code>true</code>。</p>
                                </div>



                                <dl class="details">





















                                </dl>



                            </dd>

                        </dl>





                        <h3 class="subsection-title">Type Definitions</h3>

                        <dl>

                            <dt class="">

                                <div class="nameContainer">
                                    <div class="anchor" id="~Condition">
                                    </div>
                                    <h4 class="name">
                                        Condition<span class="signature">()</span>



                                    </h4>

                                    <div class="tag-source">
                                        <a
                                            href="https://github.com/openlayers/openlayers/blob/v8.2.0/src/ol/events/condition.js">events/condition.js</a>,
                                        <a
                                            href="https://github.com/openlayers/openlayers/blob/v8.2.0/src/ol/events/condition.js#L9">line
                                            9</a>
                                    </div>

                                </div>


                            </dt>
                            <dd class="">




                                <div class="description">
                                    <p>一个函数，接受一个<a
                                            href="module-ol_MapBrowserEvent-MapBrowserEvent.html"><code>MapBrowserEvent</code></a>
                                        作为参数，并返回一个<code>{boolean}</code>。如果满足条件，则应返回true。
                                    </p>
                                </div>











                                <dl class="details">





















                                </dl>













                            </dd>

                        </dl>



                    </article>

                </section>




            </div>
        </div>
    </div>
    <script>prettyPrint();</script>
    <script src="scripts/linenumber.js"></script>
    <script src="scripts/main.js"></script>
</body>

</html>